package Niuke;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

public class fdsf {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        ArrayList<int[]> list = getScore(s);
        int res = 0;
        for (int[] one : list) {
            int left = one[0];
            int right = one[1];
            res += (left + 1) * (s.length() - right + 1) * 2;
        }
        System.out.println(res);

    }



    private static ArrayList<int[]> getScore(String str) {
        ArrayList<int[]> res = new ArrayList<>();
        if (str.length() < 2) {
            return res;
        }
        LinkedList<Integer> stack = new LinkedList<>();
        char[] chars = str.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            char c = chars[i];
            if (c == '(') {
                stack.push(i);
            } else if (c == ')') {
                if (!stack.isEmpty() && chars[stack.peek()] == '(') {
                    res.add(new int[]{stack.poll(), i + 1});
                }
            }
        }
        return res;
    }
}
